<!--
 * @Author: Zhouxin 2201_75539691@noreply.gitcode.com
 * @Date: 2024-11-25 12:19:24
 * @LastEditors: Zhouxin 2201_75539691@noreply.gitcode.com
 * @LastEditTime: 2024-11-25 15:39:30
 * @FilePath: \2024.11 .24-day11-作用域\test3.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var x;
        function fn() {
            var x;
            x = 20;
            console.log(x);//20
            x = 30;
        }
        x = 10;
        x = 30;
        fn();
        console.log(x); //30

        // ===================================
        var x;
        function x() {
            x = 40;
        }
        console.log(x);//函数体
        x = function () {
            x = 90;
        }
        x();
        x = 30;
        console.log(x);//30

        //===================================      
        var x;
        function fn1() {
            console.log(x);
        }
        function fn2() {
            var x;
            x = 1;
            fn1();
        }
        x = 20;
        x = 30;
        x = 40;
        fn2();

        //=================================== 
        var x;
        function fn() {
            var x;
            if (x) {
                x = 30;
            }
            console.log(x);//undefined
        }
        x = 20;
        fn();
        console.log(x);//20


        // ===================

        function fun(param) {
            console.log(param);//5
            param = function () {
                console.log(1);
            }
            console.log(param);//函数体
        }
        fun(5);

        // ===================
        var foo;
        function bar() {
            function foo() { }
            foo = 10;
            console.log(foo);//10
        }
        foo = 1;
        bar();
        console.log(foo);//1

        // ========================== */

        function fn() {
            var a ;
            var b;
            b = 3;
            a = b;
        }

        console.log(b);//这里打印值是多少?
        console.log(a);//这里打印值是多少?
    </script>
</body>

</html>